package com.facebook.app.shared.facebookData;

import java.util.Arrays;
import java.util.Collection;
import java.util.LinkedHashSet;
import java.util.Set;

public class DataStorage<T> {
	
	private final Set<T> dataSet;
	
	public DataStorage() {
		dataSet = new LinkedHashSet<T>();
	}
	
	public DataStorage(int initialCapacity) {
		dataSet = new LinkedHashSet<T>(initialCapacity);
	}

	public Set<T> getDataSet() {
		return dataSet;
	}
	
	@Override
	public String toString() {
		return "DataStorage: " + dataSet.toString();
	}
	
	public void addDataToSet(T data) {
		
		if (data != null) {
			dataSet.add(data);
		}
	}
	
	public void addAllDataToSet(T... dataArray) {
		
		if (dataArray != null) {
			dataSet.addAll(Arrays.asList(dataArray));
		}
	}
	
	public void addAllDataToSet(Collection<T> dataCollection) {
		
		if (dataCollection != null) {
			dataSet.addAll(dataCollection);
		}
	}
	
	public int size() {
		return dataSet.size();
	}
	
	public void clear() {
		dataSet.clear();
	}

}